package priv.demos.demo1.solution.main;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.payment.lc.pcs.service.domain.Production;
import com.payment.lc.pcs.service.domain.ProductionBizInfo;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.util.Date;

import static com.payment.lc.pcs.common.util.CommonUtil.in;

/**
 * Created on 2017/1/11.
 */
public class Main {

    public static void main(String[] args) throws Exception {
        A a = new A("a", "b");
        System.out.println(JSON.toJSONString(a));

        System.out.println(ToStringBuilder.reflectionToString(a));

        B b = new B("c", "c", "c");
        System.out.println(JSON.toJSONString(b));
        System.out.println(JSON.toJSONStringWithDateFormat(b, "yyyy-MM-dd HH:mm:ss"
                , SerializerFeature.DisableCircularReferenceDetect));

        System.out.println(b);
        System.out.println(ToStringBuilder.reflectionToString(b,ToStringStyle.NO_FIELD_NAMES_STYLE));
        System.out.println(ToStringBuilder.reflectionToString(b,ToStringStyle.SHORT_PREFIX_STYLE));
        System.out.println(ToStringBuilder.reflectionToString(b,ToStringStyle.MULTI_LINE_STYLE));
        System.out.println(ToStringBuilder.reflectionToString(b,ToStringStyle.DEFAULT_STYLE));
        System.out.println(ToStringBuilder.reflectionToString(b,ToStringStyle.SIMPLE_STYLE));
    }

}

class A {
    private String a;
    private String b;

    public A(String a, String b) {
        this.a = a;
        this.b = b;
    }

    @Override
    public String toString() {
        return JSON.toJSONString(this, SerializerFeature.DisableCircularReferenceDetect, SerializerFeature.WriteDateUseDateFormat);
    }
}

class B extends A {
    private String c;
    private Date d = new Date();

    public B(String a, String b, String c) {
        super(a, b);
        this.c = c;
    }

    public String getC() {
        return c;
    }

    public void setC(String c) {
        this.c = c;
    }

    public Date getD() {
        return d;
    }

    public void setD(Date d) {
        this.d = d;
    }
}